import {
  request,
  METHOD
} from '@/utils/request'
import axios from 'axios'

import Cookie from 'js-cookie'
const BASE_URL = process.env.VUE_APP_API_URL

/**
/*
地址管理列表
*/
export async function addressList (params) {
  return request(`${BASE_URL}/business/admin/address`, METHOD.GET, params)
}

// 设置默认地址
export async function updataDefaultShipment (id) {
  return request(`${BASE_URL}/business/admin/address/updataDefaultShipment/${id}`, METHOD.POST)
}
// 新增发货地址 1.7.1新增仓库
export async function addressListAdd (params) {
  return request(`${BASE_URL}/business/admin/address`, METHOD.POST, params)
}

// 1.7.1 修改仓库
export async function addressListEdit (params) {
  return request(`${BASE_URL}/business/admin/address/edit`, METHOD.POST, params)
}

// 1.7.1 仓库 启用/停用
export async function addressEnableOrDisable (params) {
  return request(`${BASE_URL}/business/admin/address/enableOrDisable`, METHOD.POST, params)
}

// 所在地区
export async function areaTree () {
  return request(`${BASE_URL}/business/admin/dict/area/tree`, METHOD.GET)
}
// 地址管理表 通过主键查询单条数据
export async function addressGet (id) {
  return request(`${BASE_URL}/business/admin/address/${id}`, METHOD.GET)
}

// 地址删除
export async function addressDelete (id) {
  return request(`${BASE_URL}/business/admin/address/${id}`, METHOD.DELETE)
}
// 远程锁车
export async function carLock (params) {
  return request(`${BASE_URL}/business/admin/vehicleLock/lock`, METHOD.POST, params)
}
// 物流方式
export async function listByLogisticsType () {
  return request(`${BASE_URL}/business/sysNewDict/listByLogisticsType`, METHOD.GET)
}
// 物流凭证上传
export function uploadLogisticsNoImage () {
  return `${BASE_URL}/business/admin/vehicleLogistics/uploadLogisticsNoImage`
}
// 新增修改物流
export async function vehicleLogistics (params) {
  return request(`${BASE_URL}/business/admin/vehicleLogistics`, METHOD.POST, params)
}
export async function vehicleMore (params) {
  return request(`${BASE_URL}/business/admin/putInStorageVehicleInfo/perfectBatch`, METHOD.POST, params)
}
// 修改押金和租金(月)
export async function updateDepositAndMonthRent (params) {
  return request(`${BASE_URL}/business/admin/vehicles/updateDepositAndMonthRent`, METHOD.POST, params)
}
export async function vehicleLabelAdd (params) {
  return request(`${BASE_URL}/business/admin/vehicleLabel/add`, METHOD.POST, params)
}
export async function vehicleLabelDel (params) {
  return request(`${BASE_URL}/business/admin/vehicleLabel/delete`, METHOD.POST, params)
}
// 物流分页
export async function vehicleLogisticsList (params) {
  return request(`${BASE_URL}/business/admin/vehicleLogistics`, METHOD.GET, params)
}
// 查询物流通过IDbusiness/admin/vehicleLogistics/{id}
export async function vehicleLogisticsGet (id) {
  return request(`${BASE_URL}/business/admin/vehicleLogistics/${id}`, METHOD.GET)
}
export async function usersGet (id) {
  return request(`${BASE_URL}/member/admin/users/${id}`, METHOD.GET)
}
// 物流运输中
export async function logisticsStatus2 (logisticsId) {
  return request(`${BASE_URL}/business/admin/vehicleLogistics/logisticsStatus2/${logisticsId}`, METHOD.POST)
}
// 企业logo
export function CompanyUploadLogo () {
  return `${BASE_URL}/business/admin/companies/uploadLogo`
}
// 换电卡上传
export function DinnerUpload () {
  return `${BASE_URL}/order/hq/admin/regularDinner/image/upload`
}
// 物流运输导出-1.6.9
export async function getVehicleLogistics (params) {
  const queryParams = {
    Authorization: Cookie.get('Authorization')
  }
  Object.assign(queryParams)
  return axios({
    method: 'get',
    url: `${BASE_URL}/business/admin/vehicleLogistics/export`,
    responseType: 'blob',
    params
  })
}

//  XB 查询仓库关联账号 1.7.1
export async function listWarehouseMember (id) {
  return request(`${BASE_URL}/member/admin/users/listWarehouseMember/${id}`, METHOD.GET)
}

//  仓库列表查询(启用状态) 1.7.1 XB
export async function listWarehouse () {
  return request(`${BASE_URL}/business/admin/address/listWarehouse`, METHOD.GET)
}

//  仓库列表查询-所有状态 WYJ  1.7.1
export async function allWarehouseList () {
  return request(`${BASE_URL}/business/admin/address/allWarehouseList`, METHOD.GET)
}
// 仓库关联人设为审批人或者撤销
export async function setOrRevocationApprover (data) {
  return request(`${BASE_URL}/member/admin/users/setWarehouseApproverStatus`, METHOD.GET, data)
}
